package com.wuren.foodshare.controller;

import com.wuren.foodshare.entity.User;
import com.wuren.foodshare.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/index")
    public String index(){
        return "index/index";
    }

    @RequestMapping(value = "/toRegister")
    public String toRegister(){
        return "index/register";
    }

    /**
     * 用户注册
     * @param user
     * @return
     */
    @RequestMapping(value = "/register",method = RequestMethod.POST)
    @ResponseBody
    public String addUser(User user){
        return userService.addUser(user);
    }

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String doLogin(User user){
        return null;
    }
}
